<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.bootcss.com/twitter-bootstrap/4.4.1/css/bootstrap.css" rel="stylesheet">
    <link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet">
    <link rel="stylesheet" href="./style.css">
    <title>Document</title>
</head>

<body>
    <div id="father">
        <div class="weight-info">
            <div v-bind:class="{'m-content':true,'m-switch-status':weightAddState}">
                <div class="weight-read">
                    <p class="w-time text-center">2019年12月15日 6:30pm</p>
                    <div>
                        <p class="text-center" style="margin: 0px;"><span class="data-field" style="color:red;">80.0</span>kg</p>
                    </div>
                    <div class="d-flex flex-width m-auto">
                        <div class="flex-fill">
                            <p class="text-center" style="margin: 0px;"><span class="data-second-field">27.8</span></p>
                            <p class="text-center" style="font-weight: bold;margin: 0px;">体重指数</p>
                            <p class="text-center" style="color: red;margin: 0px;">超重</p>
                        </div>
                        <div class="flex-fill">
                            <p class="text-center" style="margin: 0px;"><span class="data-second-field">175</span>cm</p>
                            <p class="text-center" style="font-weight: bold;margin: 0px;">身高</p>
                        </div>

                    </div>
                </div>
                <div class="weight-add m-auto">
                    <div class="form-group d-flex p-2">
                        <label for="weight-num" class="mt-2 mr-1">体重: </label>
                        <input class="form-control m-input" type="text" placeholder="单位(kg)" name="" id="weight-num">
                    </div>
                    <div class="form-group d-flex p-2">
                        <label for="weight-num" class="mt-2 mr-1">身高: </label>
                        <input class="form-control m-input" type="text" placeholder="单位(cm)" name="" id="weight-num">
                    </div>
                </div>
            </div>

            <div class="p-2 m-auto text-center">
                <button class="btn-rec" v-on:click="recInfo_click">&ensp;&ensp;{{weightButtonStr}}&ensp;&ensp;</button>
            </div>
        </div>
        <div class="chart-container" style="background-color: whitesmoke;">
            <div class="d-flex">
                <div class="form-group mt-2 ml-2">
                    <select id="selectState" class="form-control">
                        <option selected>日视图</option>
                        <option>周视图</option>
                        <option>月视图</option>
                    </select>
                </div>
            </div>
            <div class="m-auto" style="height:50%;width: 85%;">
                <canvas id="weightChart" height="2" width="5"></canvas>
            </div>
        </div>
    </div>

    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.11/vue.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.0/jquery.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.4.1/js/bootstrap.js"></script>
    <script src="./Chart.js"></script>
    <script>
        var vm = new Vue({
            el: "#father",
            data: {
                weightAddState: false,
                weightButtonStr: "手动记录"
            },
            methods: {
                recInfo_click: function() {
                    this.weightAddState = !this.weightAddState;

                    if (this.weightAddState) {
                        this.weightButtonStr = "记录";
                    } else {
                        this.weightButtonStr = "手动记录";
                    }
                }
            }
        });

        var weightChart = document.getElementById("weightChart").getContext('2d');
        var myChart = new Chart(weightChart, {
            type: 'bar',
            data: {
                labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
                datasets: [{
                    label: '# of Votes',
                    data: [12, 19, 3, 5, 2, 3],
                    backgroundColor: [
                        'rgba(255, 99, 132, 0.2)',
                        'rgba(54, 162, 235, 0.2)',
                        'rgba(255, 206, 86, 0.2)',
                        'rgba(75, 192, 192, 0.2)',
                        'rgba(153, 102, 255, 0.2)',
                        'rgba(255, 159, 64, 0.2)'
                    ],
                    borderColor: [
                        'rgba(255, 99, 132, 1)',
                        'rgba(54, 162, 235, 1)',
                        'rgba(255, 206, 86, 1)',
                        'rgba(75, 192, 192, 1)',
                        'rgba(153, 102, 255, 1)',
                        'rgba(255, 159, 64, 1)'
                    ],
                    borderWidth: 1
                }]
            },
            options: {
                scales: {
                    yAxes: [{
                        ticks: {
                            beginAtZero: true
                        }
                    }]
                }
            }
        });
    </script>
</body>

</html>